extends Talent

func init():
	name = "先进火控"
func _connect():
	sys.main.connect("onBattleStart",self,"run5")
	sys.main.connect("onCharaNewChara", self, "onCharaNewChara")

func onCharaNewChara(cha):
	if cha.team == 1:
		cha.addBuff(b_advancedFire.new(lv))	

func run5():
	for i in sys.main.btChas:
		if i.team == 1:
			i.addBuff(b_advancedFire.new(lv))

func get_info():
	return "我方所有角色(含召唤物)造成炮击伤害时，%d%%概率再次造成同等数值的真实伤害"%[5+lv]

class b_advancedFire extends "../../azurlane_ctrl/AzurBuff.gd":
	var tlv = 1
	func _init(tlv = 1):
		attInit()
		id = "b_advancedFire"
		dispel = 2
		buffName = "先进火控"
		self.tlv = tlv
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.atkType == sys.AtkType.GUN && sys.rndPer(5+tlv) and count < 2:
			count += 1
			atkInfo.atkCha.azurHurtChara(atkInfo.hitCha, atkInfo.hurtVal, sys.HurtType.REAL, sys.AtkType.EFF, "先进火控")
	var count = 0
	func _upS():
		count = 0

